#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
验证快乐8数据更新
"""
import csv
import os

def check_latest_data():
    """检查最新的数据"""
    data_file = os.path.join(os.path.dirname(__file__), 'scripts', 'kl8', 'kl8_history.csv')
    
    if not os.path.exists(data_file):
        print("数据文件不存在")
        return
    
    # 读取最后几行数据
    with open(data_file, 'r', newline='', encoding='utf-8') as csvfile:
        lines = csvfile.readlines()
        print(f"文件总行数: {len(lines)}")
        
        # 显示最后5行数据
        print("\n最新的5期数据:")
        for line in lines[-5:]:
            print(line.strip())
    
    # 检查是否包含2025240期数据
    with open(data_file, 'r', newline='', encoding='utf-8') as csvfile:
        reader = csv.reader(csvfile)
        found = False
        for row in reader:
            if row[0] == '2025240':
                print(f"\n找到最新的2025240期数据: {row}")
                found = True
                break
        
        if not found:
            print("\n未找到2025240期数据")

if __name__ == "__main__":
    check_latest_data()